<template>
	<view>
		<!-- 积分多少 -->
		<view class="integralbox flex ac">
			<image class="integralimage" src="../../static/jifenlogo.png"></image>
			<view style="font-size: 29rpx;margin: 0 10rpx;">兑换券余额</view>
			<view style="font-size: 35rpx;font-weight: bold;">0</view>
			<image @click="explain"  class="exchangeimage" src="../../static/icon/aa/exchange.png"></image>
		</view>
		<view style="width: 100%;height: 15rpx;background-color:#f7f7f8;"></view>
		<!-- tab -->
		<view class="navbarview">
			<view class="navbarrow">
				<view class="navbarli" @click="itemdata(0)" :class="current==0?'navbarli-in':''">兑换券获取</view>
				<view class="navbarli" @click="itemdata(1)" :class="current==1?'navbarli-in':''">兑换券支出</view>
				<view class='databox-av'
					:style='current == 0 ? "left:22%;" : "" || current == 1 ? "left:72%;" : "" '>
				</view>
			</view>
		</view>
		
		<!-- 列表数据 -->
		<view>
			<swiper class="tab-content" :autoplay="false" @change="changeSwiper" :current="current"
				:style="{ height: swiperHeight + 'px' }">
				<swiper-item>
					<scroll-view scroll-y="true" class="scoll-h">
						<block>
							<view class="listbox" :id="'content-wrap' + current">
								<!-- 暂无数据 -->
								<view class="nodatabox">
									<image style="width: 180rpx;" mode="widthFix" src="../../static/icon/aa/nodata5.png"></image>
									<view class="nodatatext">娃娃还在娃娃机里</view>
									<view class="nodataborder" @click="quzhua">去抓娃娃</view>
								</view>
							</view>
						</block>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
			}
		},
		
		onLoad(e) {
			//动态设置swiper的高度
			this.$nextTick(() => {
				this.setSwiperHeight();
			});
		},
		
		methods: {
			explain(e){
				uni.navigateTo({
				  url: '/pages/lntegralrule/lntegralrule'
				})
			},
			
			quzhua(e){
				uni.reLaunch({
				  url: '../home/home'
				})
			},
			
			itemdata(e) {
				this.current = e
			},
			
			//手动切换题目
			changeSwiper(e) {
				this.current = e.detail.current;
				//动态设置swiper的高度，使用nextTick延时设置
				this.$nextTick(() => {
					this.setSwiperHeight();
				});
			},
			
			//动态设置swiper的高度
			setSwiperHeight() {
				let element = "#content-wrap" + this.current;
				let query = uni.createSelectorQuery().in(this);
				query.select(element).boundingClientRect();
				query.exec((res) => {
					if (res && res[0]) {
						this.swiperHeight = res[0].height;
						console.log(res[0].height, "啊大大")
					}
				});
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	// 积分多少
	.integralbox {
		padding: 20rpx;
		background-color: #ffffff;
		position: relative;
	}

	.integralimage {
		width: 58rpx;
		height: 58rpx;
	}

	.exchangeimage {
		width: 186rpx;
		height: 80rpx;
		position: absolute;
		right: 0;
		top: 0;
	}

	// tab
	.navbarrow {
		width: 100%;
		height: 80rpx;
		display: flex;
		flex-direction: row;
		position: relative;
	}

	.navbarli {
		width: 50%;
		line-height: 60rpx;
		text-align: center;
		color: #b5b5b5;
		font-size: 30rpx;
	}

	.navbarli-in {
		color: #161723;
		font-size: 31rpx;
		font-weight: 600;
	}

	.databox-av {
		position: absolute;
		bottom: 19rpx;
		width: 6%;
		height: 8rpx;
		background-color: #353535;
		border-radius: 30px;
		transition: all 500ms;
		left: 18.5%;
	}
	
	
	// 暂无数据
	.nodatabox{
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction:column;
	}
	
	.nodatatext{
		font-size: 28rpx;
		color: #b5b5b5;
		margin: 20rpx 0;
	}
	
	.nodataborder{
		width: 200rpx;
		height: 60rpx;
		font-size: 28rpx;
		color: #ffffff;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 50rpx;
		background-color: #ff5e4c;
	}
	
</style>